/*** Eclipse Class Decompiler plugin, copyright (c) 2016 Chen Chao (cnfree2000@hotmail.com) ***/
package shop.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import shop.dao.BaseDao;
import shop.entity.main_type;

public class TypeDao extends BaseDao {
	private Connection conn = null;
	private PreparedStatement pstmt = null;
	private ResultSet rs = null;

	public List<main_type> findmain_type() {
		ArrayList list = new ArrayList();
		String sql = "select  * from main_type";

		try {
			this.conn = this.getConn();
			this.pstmt = this.conn.prepareStatement(sql);
			this.rs = this.pstmt.executeQuery();

			while (this.rs.next()) {
				main_type e = new main_type();
				e.setT_id(this.rs.getString("t_id"));
				e.setT_type(this.rs.getString("t_type"));
				list.add(e);
			}
		} catch (Exception arg6) {
			arg6.printStackTrace();
		} finally {
			this.closeAll(this.conn, this.pstmt, this.rs);
		}

		return list;
	}

	public String findByID(int typeID) {
		String pt = null;
		String sql = "select t_type from main_type where t_id = ? ";

		try {
			this.conn = this.getConn();
			this.pstmt = this.conn.prepareStatement(sql);
			this.pstmt.setLong(1, (long) typeID);

			for (this.rs = this.pstmt.executeQuery(); this.rs.next(); pt = this.rs.getString("t_type")) {
				;
			}
		} catch (Exception arg7) {
			arg7.printStackTrace();
		} finally {
			this.closeAll(this.conn, this.pstmt, this.rs);
		}

		return pt;
	}
}